#define _CRT_SECURE_NO_WARNINGS 1

#include <vector>

using namespace std;

class Solution {
public:
    vector<int> getRow(int rowIndex) {
        vector<vector<int>> ret;
        ret.reserve(rowIndex + 1);
        for (int i = 0; i < rowIndex + 1; ++i)
        {
            vector<int> v;
            for (int j = 0; j <= i; ++j)
            {
                if (j == 0)
                {
                    v.push_back(1);
                    continue;
                }
                if (j == i)
                {
                    v.push_back(1);
                    continue;
                }
                v.push_back(ret[i - 1][j - 1] + ret[i - 1][j]);
            }
            ret.push_back(v);
        }
        return ret[rowIndex];
    }
};